001 /*
002 * Copyright 2005 Stephen J. McConnell
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
013 * implied.
014 *
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package net.dpml.library.info;
020
021 import net.dpml.library.Data;
022
023 import java.util.Properties;
024
025 import org.w3c.dom.Element;
026
027 /**
028 * Base class for a data directives.
029 *
030 * @author <a href="http://www.dpml.net">The Digital Product Meta Library</a>
031 * @version 1.0.0
032 */
033 public class DataDirective extends AbstractDirective implements Data
034 {
035 private final Element m_element;
036
037 /**
038 * Creation of a new data directive using a DOM element as the
039 * datastructure definition.
040 * @param element the DOM element
041 */
042 public DataDirective( Element element )
043 {
044 super();
045 m_element = element;
046 }
047
048 /**
049 * Creation of a new data directive using a supplied properties argument.
050 * @param properties associated properties
051 */
052 public DataDirective( Properties properties )
053 {
054 super( properties );
055 m_element = null;
056 }
057
058 /**
059 * Return the datatype element.
060 * @return the DOM element
061 */
062 public Element getElement()
063 {
064 return m_element;
065 }
066
067 /**
068 * Compare this object with another for equality.
069 * @param other the other object
070 * @return true if equal
071 */
072 public boolean equals( Object other )
073 {
074 if( super.equals( other ) && ( other instanceof DataDirective ) )
075 {
076 DataDirective object = (DataDirective) other;
077 return equals( m_element, object.m_element );
078 }
079 else
080 {
081 return false;
082 }
083 }
084
085 /**
086 * Compute the hash value.
087 * @return the hascode value
088 */
089 public int hashCode()
090 {
091 int hash = super.hashCode();
092 hash ^= hashValue( m_element );
093 return hash;
094 }
095 }